function CustomizeInitialsAssistant(title, listData, updateCallback) {
	this.listTitle = title;
	this.listData = listData;
	this.updateCallback = updateCallback;
}

CustomizeInitialsAssistant.prototype.setup = function() {
	var items = new Array();
	for ( var i = 0; i < this.listData.length; ++i) {
		items.push( {
			data : this.listData[i]
		});
	}

	// setup list
	this.listModel = {
		listTitle : $L(this.listTitle),
		items : items
	};

	this.list = this.controller.get('wordsList');
	this.listAtts = {
		itemTemplate : 'customize-initials/listitem',
		listTemplate : 'customize-initials/listcontainer',
		addItemLabel : $L("Add..."),
		swipeToDelete : true,
		reorderable : false,
		emptyTemplate : 'customize-initials/emptylist'
	};

	this.controller.setupWidget('wordsList', this.listAtts, this.listModel);

	this.controller.setupWidget(Mojo.Menu.commandMenu, undefined, {
		visible : true,
		toggleCmd : 'ok',
		items : [ {}, {
			items : [ {
				label : 'ok',
				command : 'ok'
			}, {
				label : $L('Cancel'),
				command : 'cancel'
			} ]
		}, {} ]
	});

	// Bind event handlers ahead of time so we have references we can use in
	// cleanup
	 this.listChangeHandler = this.listChangeHandler.bind(this);
	this.listAddHandler = this.listAddHandler.bind(this);
	this.listDeleteHandler = this.listDeleteHandler.bind(this);

	this.controller.listen(this.list, Mojo.Event.listChange,
			this.listChangeHandler);
	this.controller.listen(this.list, Mojo.Event.listAdd, this.listAddHandler);
	this.controller.listen(this.list, Mojo.Event.listDelete,
			this.listDeleteHandler);
};

// Adds a new item to the list.
CustomizeInitialsAssistant.prototype.listAddHandler = function(event) {

	/*
	 * // This works, but refreshes the whole list:
	 * this.currentModel.items.push({data:"New item"});
	 * this.controller.modelChanged(this.currentModel, this);
	 */

	// The 'noticeAddedItems' API will inserts the item where indicated,
	// and then the list can potentially update only the added item.
	var newItem = {
		data : $L("New item")
	};
	this.listModel.items.push(newItem);
	this.list.mojo.noticeAddedItems(this.listModel.items.length, [ newItem ]);
};

CustomizeInitialsAssistant.prototype.listDeleteHandler = function(event) {
	this.listModel.items.splice(this.listModel.items.indexOf(event.item), 1);
};

CustomizeInitialsAssistant.prototype.listChangeHandler = function(event) {
	if(event.originalEvent.target.tagName == "INPUT") {
		event.item.data = event.originalEvent.target.value;
	}
},


CustomizeInitialsAssistant.prototype.activate = function(event) {
};

CustomizeInitialsAssistant.prototype.handleCommand = function(event) {
	if (event.type == Mojo.Event.command) {
		switch (event.command) {
		case "ok":
			var array = new Array();
			for ( var i = 0; i < this.listModel.items.length; ++i) {
				array.push(this.listModel.items[i].data);
			}
			this.updateCallback(array);
			eliza.mainAssistant.controller.stageController.popScene(0);
			eliza.mainAssistant.reset();
			break;
		case 'cancel':
			eliza.mainAssistant.controller.stageController.popScene(0);
			break;
		default:
			Mojo.Log.info(event.command);
		}
	}
};

CustomizeInitialsAssistant.prototype.deactivate = function(event) {
	this.controller.stopListening(this.list, Mojo.Event.listChange,
			this.listChangeHandler);
	this.controller.stopListening(this.list, Mojo.Event.listAdd,
			this.listAddHandler);
	this.controller.stopListening(this.list, Mojo.Event.listDelete,
			this.listDeleteHandler);
};

CustomizeInitialsAssistant.prototype.cleanup = function(event) {
};
